#ifndef MENUMANAGER_H_H_H_H_
#define MENUMANAGER_H_H_H_H_
#include <string>
#include <QStringList>

class QAction;
class QMenu;

class MainWindow;
class MenuItem
{
public:
	MenuItem();
	MenuItem(MenuItem*);
	~MenuItem();

public:
	void setComamnd(const std::string& name);
	std::string command()const;

	bool hasItem()const;
	MenuItem* findItem(const std::string& name);
	MenuItem* copy()const;	
	int count()const;

	void appendItem(MenuItem*);
	bool insertItem(MenuItem*,MenuItem*);
	void removeItem(MenuItem*);
	void clear();

	MenuItem& operator <<(MenuItem* item);
	MenuItem& operator <<(const std::string& command);
	QList<MenuItem*>getItems()const;

private:
	std::string _name;
	QList<MenuItem*> _items;


};
class MenuManager
{
public:
	MenuManager(void);
	~MenuManager(void);

public:
	static MenuManager* Instance();
	static void destruct();

	void setup(MenuItem* item);
	void setupContextMenu(MenuItem* item,QMenu &menu)const;
private:

	void setup(MenuItem* item,QMenu*)const;
	QAction* findAction(const QList<QAction*>&, const QString&)const;
	QList<QAction*>findActions(const QList<QAction*>&,const QString&)const;

private:
	static MenuManager* _instance;
};
#endif